/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2022-01-16 18:59:20
 * @LastEditors: GGB
 * @LastEditTime: 2022-01-16 19:29:53
 */
import { useState, useEffect } from 'react'
import axios from 'axios';
const useURLLloader = (url) => { 
    const [data, setData] = useState(null)
    const [loading, setLoading] = useState(false)
    /**
     * 如果后面的数组 表示依赖的函数
     */
    useEffect(() => { 
        setLoading(true)
        axios.get(url).then(result => { 
            setData(result.data)
        }).finally(() => { 
            setLoading(false)
        })
    }, [url])
    return [data,loading]
}

export default useURLLloader